from locals import *
import objects

class Door(objects.Object):
	graphic = "door.png"
	open = False
	key = "key"
	
	def draw(self, surface):
		if not self.open:
			super(Door, self).draw(surface)
		
	def passable(self, object):
		return self.open
		
	def push(self, pusher, movement, speed):
		if self.key in pusher.items:
			self.open = True
			pusher.items.remove(self.key)
			return True
			
class ChipDoor(Door):
	graphic = "chip_door.png"

	def __init__(self, map, position, chips):
		super(ChipDoor, self).__init__(map, position)
		
		self.chips = chips

	def save(self, variables):
		return "%s, %s" % (super(Door, self).save(variables), str(self.chips))

	def push(self, pusher, movement, speed):
		if pusher.items.count("chip") >= self.chips:
			self.open = True
			return True
		else:
			print "You need %d chips to open this door." % self.chips

class RedDoor(Door):
	graphic = "red_door.png"
	key = "red key"

class BlueDoor(Door):
	graphic = "blue_door.png"
	key = "blue key"
			
class GreenDoor(Door):
	graphic = "green_door.png"
	key = "green key"
	
	def push(self, pusher, movement, speed):
		if self.key in pusher.items:
			self.open = True
			return True
			
class YellowDoor(Door):
	graphic = "yellow_door.png"
	key = "yellow key"